import {request} from "@/network/request";

// 提交订单
export function createOrder(params) {
	return request({
		url: '/api/orders',
		method: 'POST',
		params
	})
}

// 获取订单预览
export function getOrderPreview() {
	return request({
		url: '/api/orders/preview',
		method: 'GET'
	})
}

// 获取支付二维码
export function payOrder(order, params) {
	return request({
		url: `/api/orders/${order}/pay`,
		method: 'GET',
		params
	})
}

// 模拟支付成功
export function paySuccess(order, params) {
	return request({
		url: `/api/orders/${order}/paytest`,
		method: 'PATCH', params
	})
}

// 获取订单状态
export function payOrderStatus(order) {
	return request({
		url: `/api/orders/${order}/status`,
		method: 'GET',
	})
}

// 获取订单列表
export function getOrderList(params) {
	return request({
		url: '/api/orders',
		method: 'GET',
		params
	})
}

// 获取订单详情
export function getOrderDetail(order) {
	return request({
		url: `/api/orders/${order}`,
		method: 'GET',
		params: {
			include: 'user,orderDetails.goods'
		}
	})
}

// 确认订单
export function confirmOrder(order) {
	return request({
		url: `/api/orders/${order}/confirm`,
		method: 'PATCH',
	})
}

// 获取物流详情
export function viewExpress(order) {
	return request({
		url: `/api/orders/${order}/express`,
		method: 'GET',
	})
}

